@include('admin.header')

<style type="text/css">
  .opartion {
    width: 350px;
  }

  .pagination {
    list-style: none;
    float: right;
  }

  .pagination li {
    float: left;
    padding-left: 5px;
    padding-right: 5px;
  }

  .input_search {
    margin-top: 10px;
  }
</style>

<div class="wrap">
  <div class="margin-bottom-20">

            <span class="r">共有数据：<strong>{{$data->total()}}</strong> 条</span>
        </div>
      <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a class="btn btn-primary radius" id="add_currency">添加</a></span> </div>
  </div>
  <form class="form-horizontal js-ajax-form" method="post" novalidate="novalidate">
    <table class="table table-hover table-bordered">
      <thead>
      <tr>
        <th>货币ID</th>
        <th>货币英文简写</th>
        <th>存放汇率 </th>
        <th>货币单位</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      @foreach($data as $val)
      <tr>
        <td>{{$val->currencyid}}</td>
        <td>{{$val->currency_type}}</td>
        <td>{{$val->exchange_rate}}</td>
        <td>{{$val->currency_unit}}</td>
        <td>
         <span><a _id="{{$val->currencyid}}" class="edit_currency">编辑</a></span> ｜
          <a href="javascript:void(0)" rel="{{$val->currencyid}}" class="js-rule-delete">删除</a>
        </td>
      </tr>
      @endforeach
      </tbody>
    </table>

    <!-- 分页 -->
    @if (!empty($data))
    <div class="page_list">
        {{$data->links()}}
    </div>
    @endif
  </form>
</div>

<script>
$(function(){
      //添加货币
    $('#add_currency').click(function() {
      open_iframe_layer('/currency/add_currency');
    });

    //编辑货币
    $('.edit_currency').click(function() {
      var id = $(this).attr('_id') || 0;
      open_iframe_layer('/currency/add_currency?currencyid='+id);
    });

    $('.js-rule-delete').click(function(){
    var id = $(this).attr('rel');
    layer.confirm('你确定要删除吗？', {
      btn: ['确定','取消']
    }, function(){
      $.post('{{asset("currency/del")}}',{id:id},function (msg) {
        if(msg.status == 1){
          layer.alert(msg.info, {
            title: '提示',
            icon: 1,
          });
          window.location.href = '{{asset("currency/currency")}}';
        }else{
          layer.alert(msg.info, {
            title: '提示',
            icon: 2,
          });
        }
      },'json');
    },function() {

    });
  });
});
//详情
// $('.apply_action').click(function() {
//   var id = $(this).attr('_id');
//    if(confirm("确定要审核通过吗？")){
//       $.ajax({
//             type: 'GET',
//             url: '/system/apply_action?id='+id,
//             dataType: 'json',
//             success: function(data){
               
//             },
           
//          });
//    }
        
//    });


</script>